define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	$scope.form.father_id=params.father_id;





		/**
	 	* 下载模板
	 	*/
		$scope.downloadTemplate=function(){
			window.location.href = "assets/template/recruitStudent.xls";
		}


		//查询
		$scope.find = function(){
			httpService.postpage(app.urls.newStudent_selectAll, $scope.form, function(data){
				if("0000" === data.code){
					$scope.rows = data.data;
				}else{
					alert(data.msg);
				}
			});
		}
		$scope.find();

		//导入
		$scope.import = function(){
			eventBusService.publish("modal.page","modules/content/recruitstudent/roster/import");
		}

		//添加
		$scope.add = function(){
			eventBusService.publish("modal.page","modules/content/recruitstudent/roster/add");
		}

		//编辑
		$scope.edit = function() {
			var values = [];
			$('input[name="dataPk"]:checked').each(function() {
				values.push($(this).val());
			});

			if(values.length < 1) {
				eventBusService.publish("modal.alert", {"content":"请选择一条数据。"});
			}else if(values.length > 1) {
				eventBusService.publish("modal.alert", {"content":"不能同时选择多行数据，请选择一条数据。"});
			}else{
				eventBusService.publish("modal.page", "modules/content/recruitstudent/roster/edit?id="+values[0]);
			}
		}

		//删除
		$scope.remove = function() {
			var values = [];
			$('input[name="dataPk"]:checked').each(function(){
				values.push($(this).val());
			});

			if(values.length < 1) {
				eventBusService.publish("modal.alert", {"content":"请选择一条数据。"});
			}else if(values.length > 1){
				eventBusService.publish("modal.alert", {"content":"不能同时选择多行数据，请选择一条数据。"});
			}else{
				eventBusService.publish("modal.alert", {"content":"确认删除这条记录吗？", "isAutoClose":false,
					"confirm":function(){
						httpService.post(app.urls.newStudent_delete,{"id":values[0]}, function(data) {
							if(data.code=="0000"){
								eventBusService.publish("modal.alert", {"content": "删除成功"});
								eventBusService.publish("content.page.reload", data.data);
							}else{
								eventBusService.publish("modal.alert", {"content":"删除失败。"});
							}
						});
					}
				});
			}
		}

		//按钮点击事件-条件查询
		$scope.select = function(){
			$scope.page.current = 1;
			$scope.find();
		}


		//接收数据刷新
		eventBusService.subscribe('content.page.reload', function(event,data) {
			$scope.select();
		});
		//选择数据
		$scope.optData = function (element) {
			if($(element).find("input[name='dataPk']").is(":checked")){
				$(element).find("input[name='dataPk']").prop("checked",false);
				$(element).removeClass("opt_tr");
			}else{
				$(element).find("input[name='dataPk']").prop("checked",true);
				$(element).addClass("opt_tr");
			}
		}
		$scope.checkAll = function(target) {
			$("#" + $scope.controllerName + " input[name='dataPk']").each(function() {
				if ($(this).prop("checked")) {
					$(this).prop('checked', false);
					$(this).parents("tr").removeClass("opt_tr");
				} else {
					$(this).prop('checked', true);
					$(this).parents("tr").addClass("opt_tr");
				}
			})
		}
}}});